﻿using System;
using System.Collections.Generic;
using System.Linq;
using FollowMe.Model;
using FollowMe.Infrastructure.UnitOfWork;

namespace FollowMe.Repository
{
    /// <summary>
    /// The Friend Repo/Table
    /// </summary>
    public class FriendRepository : Repository<Friend, Guid>, IFriendRepository
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="FriendRepository"/> class.
        /// </summary>
        /// <param name="fm">The fmcontext/dbcontext</param>
        public FriendRepository(IContext fm)
            : base(fm)
        { }

        /// <summary>
        /// Initializes a new instance of the <see cref="FriendRepository"/> class.
        /// </summary>
        public FriendRepository() { }

        /// <summary>
        /// Finds the friends that the user added.
        /// </summary>
        /// <param name="Id">The identifier.</param>
        /// <returns></returns>
        public IEnumerable<Friend> FindIAddedBy(Guid Id)
        {
            return GetObjectSet().Where<Friend>(m => m.MemberAddingID == Id);
        }

        /// <summary>
        /// Finds the friends that added the particular user
        /// </summary>
        /// <param name="Id">The identifier.</param>
        /// <returns></returns>
        public IEnumerable<Friend> FindAddedMeBy(Guid Id)
        {
            return GetObjectSet().Where<Friend>(m => m.FriendAddedID == Id);
        }
    }
}
